use chacha20::XNonce;
use getrandom::{getrandom, Error as GetRandomError};

pub trait NewNonce: Sized {
    fn new() -> Result<Self, GetRandomError>;
}

pub type Nonce24 = XNonce;

impl NewNonce for Nonce24 {
    fn new() -> Result<Self, GetRandomError> {
        let mut nonce = Self::default();
        getrandom(&mut nonce)?;
        Ok(nonce)
    }
}
